<template>
  <div class="news-line">
    <div class="news-line-header">
      <span>
        用户名
        <i class="user-vip-icon" />
      </span>
      <span>发布{{props.from}}</span>
      <span>{{props.time}}</span>
    </div>
    <div class="news-line-body">
      <a class="title">{{props.title}}</a>
      <div class="main">
        <img class="left" src="~@/assets/images/home/news1.jpg" />
        <div class="right">
          <div class="pretext">{{props.pretext}}</div>
          <div class="line-bar">
            <i class="icon-zan" :class="zan?'active':''" @click="zanClick">{{(zan?props.count+1:props.count)+' 赞'}}</i>
            <i class="icon-cai" :class="cai?'active':''" @click="caiClick">踩</i>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang='ts'>
import { Component, Vue, Prop } from "nuxt-property-decorator";

@Component
export default class extends Vue {
  @Prop() props!: object;
  zan: boolean = false;
  cai: boolean = false;

  zanClick() {
    this.zan = !this.zan;
    // 调用点赞方法
  }

  caiClick() {
    this.cai = !this.cai;
    //调用点踩方法
  }
}
</script>

<style lang='less' scoped>
.news-line {
  .wh(100%, auto);
  .flex-box(column, flex-start);
  padding-bottom: 10px;
  border-bottom: 1px solid #f0f0f2;
  .news-line-header {
    .wh(100%, 20px);
    color: #999aaa;
  }
  .news-line-body {
    .wh(100%, auto);
    .flex-box(column, flex-start, flex-start);

    .title {
      font-size: 18px;
      font-weight: bold;
      color: #000;
      cursor: pointer;
    }
    .main {
      .wh(auto, 140px);
      .flex-box(row, flex-start, flex-start);
      .left {
        .wh(auto, 140px);
        cursor: pointer;
      }
      .right {
        .wh(auto, 140px);
        padding-left: 10px;
        .flex-box(column, space-between, flex-start);
        .pretext {
          cursor: pointer;
        }
      }
    }
  }
}
.icon-zan {
  display: inline-block;
  .wh(80px, 16px);
  line-height: 16px;
  background: url("~@/assets/images/zan.png");
  background-repeat: no-repeat;
  background-size: auto 100%;
  cursor: pointer;
  padding-left: 25px;
  &:hover {
    opacity: 0.6;
  }
}
.icon-cai {
  display: inline-block;
  .wh(40px, 16px);
  line-height: 16px;
  background: url("~@/assets/images/cai.png");
  background-repeat: no-repeat;
  background-size: auto 100%;
  cursor: pointer;
  padding-left: 25px;
  &:hover {
    opacity: 0.6;
  }
}
.active {
  color: red !important;
}
</style>